<template>
  <div>
    <el-drawer
      v-model="drawer"
      :title="title"
      direction="btt"
      :before-close="handleClose"
      size="60%"
      :show-close="false"
    >
      <div v-html="content"></div>
      <template #footer>
        <div class="flex justify-center w-full">
          <div
            class="min-w-90px h-40px text-20px font-bold bg-[#111] text-white flex flex-center rounded-20px px-20px"
            @click="drawer = false"
          >
            关闭
          </div>
        </div>
      </template>
    </el-drawer>
  </div>
</template>

<script setup>
import { ref } from 'vue'
import { searchTalentSingleLib } from '@/api/common'
import { getLangOrNullValue } from '@/utils/lang'
import Cookies from 'js-cookie'

const drawer = ref(false)
const content = ref()
const title = ref()

const init = (initTitle, code) => {
  drawer.value = true
  title.value = initTitle
  searchTalentSingleLib({
    code: code,
    current: 1,
    language: getLangOrNullValue(Cookies.get('language')),
    size: 1,
  }).then((res) => {
    if (res.code === 20000 && res.data.records.length > 0)
      content.value = res.data.records?.[0]?.langValueHtml
  })
}

defineExpose({
  init,
})
</script>
